<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>04-context参数</title>
    <script src="https://unpkg.com/vue@next"></script>
  </head>
  <body>
    <div id="root"></div>

    <script>
      const app = Vue.createApp({

    
        methods: {
          handleClcik() {
            alert(666);
          },
        },

        template: `
                    <child @change="handleClcik">
                        hello world
                    </child>
                `,
      });

      app.component("child", {
        //mounted(){
        //    this.$emit("change");
        //},

        template: `<div @click="handleClick">child</div>`,

        setup(props, context) {
          const { h } = Vue;

          const { attrs, slots, emit } = context;

          function handleClick() {
            emit("change");
          }
          return { handleClick };

          //console.log(attrs); //None-Props属性

          //console.log(slots.default());

          //return () => h("div", {}, slots.default());
        },
      });

      const vm = app.mount("#root");
    </script>
  </body>
</html>
